home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / windows / wdj1096.zip / ZOLMAN.ZIP / MDIICONS.ZIP / MAINFRM.CPP < prev    next >
C/C++ Source or Header  |  1996-02-16  |  4KB  |  170 lines

  1. // mainfrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "icons.h"
  6.  
  7. #include "mainfrm.h"
  8.  
  9. #ifdef _DEBUG
  10. #undef THIS_FILE
  11. static char BASED_CODE THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14.  
  15.  
  16. // Keep track of MDI Child Frame Windows
  17. int CChildIconWnd::s_iNumChild = 0 ;
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CChildIconWnd
  21.  
  22. IMPLEMENT_DYNCREATE(CChildIconWnd, CMDIChildWnd)   
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. //  Constructor
  26. //
  27. CChildIconWnd::CChildIconWnd()
  28. {   
  29.     // Keep track of MDI Child Frame Windows
  30.     s_iNumChild++    ;
  31. }
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. //  Destructor
  35. //
  36. CChildIconWnd::~CChildIconWnd()
  37. {
  38. }
  39.  
  40.  
  41. BEGIN_MESSAGE_MAP(CChildIconWnd, CMDIChildWnd)
  42.     //{{AFX_MSG_MAP(CChildIconWnd)  
  43.     //}}AFX_MSG_MAP
  44. END_MESSAGE_MAP()
  45.  
  46.  
  47. static UINT s_hIcon [ 2 ] = { IDI_EVEN, IDI_ODD } ;
  48.  
  49.  
  50. BOOL CChildIconWnd::PreCreateWindow ( 
  51.                     CREATESTRUCT& cs  // @parm A CREATESTRUCT structure.
  52.                     ) 
  53. {
  54.  
  55.     HICON hIcon = ((CIconsApp*)AfxGetApp()) -> 
  56.                         LoadIcon ( s_hIcon [ s_iNumChild %2 ]  ) ;
  57.     
  58.     cs . lpszClass = AfxRegisterWndClass( CS_HREDRAW | CS_VREDRAW, 0, 0, 
  59.                         hIcon );
  60.     
  61.     return TRUE ;  // The window creation should continue
  62. }
  63.  
  64.  
  65.  
  66.  
  67.  
  68. /////////////////////////////////////////////////////////////////////////////
  69. // CMainFrame
  70.  
  71. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  72.  
  73. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  74.     //{{AFX_MSG_MAP(CMainFrame)
  75.         // NOTE - the ClassWizard will add and remove mapping macros here.
  76.         //    DO NOT EDIT what you see in these blocks of generated code !
  77.     ON_WM_CREATE()
  78.     //}}AFX_MSG_MAP
  79.     // Global help commands
  80.     ON_COMMAND(ID_HELP_INDEX, CMDIFrameWnd::OnHelpIndex)
  81.     ON_COMMAND(ID_HELP_USING, CMDIFrameWnd::OnHelpUsing)
  82.     ON_COMMAND(ID_HELP, CMDIFrameWnd::OnHelp)
  83.     ON_COMMAND(ID_CONTEXT_HELP, CMDIFrameWnd::OnContextHelp)
  84.     ON_COMMAND(ID_DEFAULT_HELP, CMDIFrameWnd::OnHelpIndex)
  85. END_MESSAGE_MAP()
  86.  
  87. /////////////////////////////////////////////////////////////////////////////
  88. // arrays of IDs used to initialize control bars
  89.  
  90. // toolbar buttons - IDs are command buttons
  91. static UINT BASED_CODE buttons[] =
  92. {
  93.     // same order as in the bitmap 'toolbar.bmp'
  94.     ID_FILE_NEW,
  95.     ID_FILE_OPEN,
  96.     ID_FILE_SAVE,
  97.         ID_SEPARATOR,
  98.     ID_EDIT_CUT,
  99.     ID_EDIT_COPY,
  100.     ID_EDIT_PASTE,
  101.         ID_SEPARATOR,
  102.     ID_FILE_PRINT,
  103.     ID_APP_ABOUT,
  104.     ID_CONTEXT_HELP,
  105. };
  106.  
  107. static UINT BASED_CODE indicators[] =
  108. {
  109.     ID_SEPARATOR,           // status line indicator
  110.     ID_INDICATOR_CAPS,
  111.     ID_INDICATOR_NUM,
  112.     ID_INDICATOR_SCRL,
  113. };
  114.  
  115. /////////////////////////////////////////////////////////////////////////////
  116. // CMainFrame construction/destruction
  117.  
  118. CMainFrame::CMainFrame()
  119. {
  120.     // TODO: add member initialization code here
  121. }
  122.  
  123. CMainFrame::~CMainFrame()
  124. {
  125. }
  126.  
  127. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  128. {
  129.     if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  130.         return -1;
  131.  
  132.     if (!m_wndToolBar.Create(this) ||
  133.         !m_wndToolBar.LoadBitmap(IDR_MAINFRAME) ||
  134.         !m_wndToolBar.SetButtons(buttons,
  135.           sizeof(buttons)/sizeof(UINT)))
  136.     {
  137.         TRACE("Failed to create toolbar\n");
  138.         return -1;      // fail to create
  139.     }
  140.  
  141.     if (!m_wndStatusBar.Create(this) ||
  142.         !m_wndStatusBar.SetIndicators(indicators,
  143.           sizeof(indicators)/sizeof(UINT)))
  144.     {
  145.         TRACE("Failed to create status bar\n");
  146.         return -1;      // fail to create
  147.     }
  148.  
  149.     return 0;
  150. }
  151.  
  152. /////////////////////////////////////////////////////////////////////////////
  153. // CMainFrame diagnostics
  154.  
  155. #ifdef _DEBUG
  156. void CMainFrame::AssertValid() const
  157. {
  158.     CMDIFrameWnd::AssertValid();
  159. }
  160.  
  161. void CMainFrame::Dump(CDumpContext& dc) const
  162. {
  163.     CMDIFrameWnd::Dump(dc);
  164. }
  165.  
  166. #endif //_DEBUG
  167.  
  168. /////////////////////////////////////////////////////////////////////////////
  169. // CMainFrame message handlers
  170.